package com.zhouyu;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.config.*;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

public class Consumer {

    public static void main(String[] args) throws IOException {
        ReferenceConfig<HelloService> ref = new ReferenceConfig<>();
        ref.setInterface(HelloService.class);
        ref.setCheck(false);
        ref.setProtocol(CommonConstants.TRIPLE);
        ref.setLazy(true);
        ref.setTimeout(100000);
        ref.setApplication(new ApplicationConfig("demo-consumer"));
        ref.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));

        final HelloService helloService = ref.get();

        System.out.println("dubbo ref started");

        User user = helloService.sayHello(HelloRequest.newBuilder().setName("zhouyu-java").build());
        System.out.println(user);
        System.in.read();
    }
}
